<template>
  <div class="mainos">
    <div class="main_spac1 paddingBottom5">
      <div class="main_white padding10 paddingBottom20">
        <div class="main_crumbs boxdq">
          <div class="main_crumbs_l">
            <a href="javascript:;" @click="$router.back(-1)">
              <i class="el-icon-arrow-down"></i>返回
            </a>
            <em>|</em>
            <span>查看订单</span>
          </div>
        </div>
        <div class="main_tile boxdq marginTop10">
          <div class="main_tile_l marginLeft0"><em></em>基础信息</div>
        </div>
        <div class="info">
           <div class="part">
              <div><span>客户：</span>{{ data.company_name }}</div>
              <div><span>账单号：</span>{{ data.order_sn }}</div>
              <div><span>账期：</span>{{ data.payment_days }}</div>
              <div><span>创建日期：</span>{{data.created_at? parseTime(data.created_at, "{y}-{m}-{d}"): ""}}</div>
           </div>
           <div class="part">
              <div><span>状态：</span>{{ pay_status[data.pay_status]}}</div>
              <div><span>第</span> {{ data.notice_days_num}} <span>天提醒</span> </div>
              <div><span>第</span> {{ data.forbid_days_num}} <span>天关系统</span></div>
              <div><span>配送金额：</span>{{data.send_money}}</div>
           </div>
           <div class="part">
              <div><span>佣金比例：</span>{{ data.commission_rate }}</div>
              <div><span>佣金金额：</span>{{ data.commission }}</div>
              <div><span>抹零金额：</span>{{ data.zero_money }}</div>
              <div><span>实收金额：</span>{{data.real_money}}</div>
           </div>
        </div>
        <div class="main_tile boxdq marginTop10">
          <div class="main_tile_l marginLeft0"><em></em>收款信息</div>
        </div>
        <div class="main_table marginTop0 info2 ">
           <div class="row"><span>支付剩余天数：</span>{{data.time_left}}</div>
           <!-- 未支付没有支付方式   -->
           <div class="row"><span>支付方式：</span>{{data.pay_status==0 ?'': data.pay_type==1?'在线支付':data.pay_type==2?'线下收款':''}}</div> 
           <div class="row"><span>收款渠道：</span>{{data.collection_channels==1?'银联支付':data.collection_channels==2?'银行转账':data.collection_channels==3?'支付宝':data.collection_channels==4?'微信':data.collection_channels==5?'现金':''}}</div>
           <div class="row"><span>付款人：</span>{{data.payer}}</div>
           <div class="row"><span>备注：</span>{{data.remark}}</div>
           <div class="row"><span>凭证：</span>
              <div class="imgs">
                 <img v-for="(item,index) in filelist" style="width:120px;height:120px;margin-right:20px;" :src="avatar.img_prefix+item" :key="index" @click="handlePictureCardPreview(avatar.img_prefix+item)">
              </div>
               <el-dialog :visible.sync="dialogVisible">
                  <img style="width:100%" :src="dialogImageUrl" alt />
               </el-dialog>
           </div>

        </div>
        <div class="main_tile boxdq marginTop20">
          <div class="main_tile_l marginLeft0"><em></em>生命周期</div>
        </div>
        <div class="main_table marginTop0">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="logs"
            element-loading-text="加载中"
            fit
            highlight-current-row
          >
            <el-table-column
              label="管理员"
              prop="admin_name"
              class-name="main_hei"
            />
            <el-table-column
              label="操作"
              prop="operate.name"
              class-name="main_hei"
            />
            <el-table-column label="内容" prop="content" class-name="main_hei">
              <!-- <template slot-scope="scope">
                <div
                  v-for="(content, index) in scope.row.content"
                  :key="index"
                  class="marginTop5 marginBottom5"
                >
                  {{ content }}
                </div>
              </template> -->
            </el-table-column>
            <el-table-column label="IP" prop="ip" class-name="main_hei" />
            <el-table-column
              label="时间"
              prop="created_at"
              class-name="main_hei"
            >
              <template slot-scope="scope">{{
                parseTime(scope.row.created_at)
              }}</template>
            </el-table-column>
          </el-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  offlineCommissionDetail,
  getBillLife,
} from "@/api/brokerage/offline";
import { parseTime } from "@/utils/index";
import { mapGetters } from "vuex";

export default {
  computed: {
    ...mapGetters(["avatar"]),
  },

  data() {
    return {
      // 时间
      parseTime,
      // 基本信息
      data:{},
      logs:[],
      type: "", //1.订单2.退货单
      listLoading: false,
      // id
      id: this.$route.query.id,
      pay_status:['待支付','已支付','已作废'],

      filelist: [],
      dialogImageUrl: "",
      dialogVisible: false,
    };
  },
  created() {
    // 基本信息
    this.getData();
  },
  methods: {
    // 基本信息
    getData() {
      let data ={ id: this.id }
      offlineCommissionDetail(data).then((res) => {
        if (res.errcode == 0) {
           this.data = res.data;
           if(res.data.credentials){
              this.filelist = res.data.credentials.split(',');
           }
        } else {
          this.$message.error(res.errmsg);
        }
      });

      getBillLife(data).then((res) => {
        if (res.errcode == 0) {
          this.logs = res.data.list;
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
    // 上传图片-查看
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file;
      this.dialogVisible = true;
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/styles/variables.scss";

.mainos {
  .main_tile {
    .mainos_tile_r {
      color: $colour_red;
      font-size: $font_14;
    }
  }
  .mainor_ex {
    position: fixed;
    width: 220px;
    height: 100%;
    background: $white;
    box-shadow: 0 6px 10px rgba(0, 21, 41, 0.08);
    top: 0;
    right: 0;
    z-index: 9999;
    transition: all 0.5s;
    transform: translate3d(100%, 0, 0);
    &.on {
      transform: translate3d(0, 0, 0);
    }
    .mainor_exb {
      position: absolute;
      width: 100%;
      height: calc(100% - 60px);
      overflow-y: auto;
      h3 {
        font-size: $font_16;
        color: $colour_18;
        height: 50px;
        line-height: 50px;
        border-bottom: 1px solid $colour_e6;
        padding-left: 20px;
      }
      .mainor_exb_an {
        padding-left: 20px;
        margin-top: 15px;
        /deep/.el-checkbox {
          display: block;
          margin-top: 15px;
          margin-bottom: 15px;
        }
      }
    }
    .mainor_exb_b {
      position: absolute;
      bottom: 0;
      width: 100%;
      border-top: 1px solid $colour_e6;
      height: 55px;
      text-align: center;
      /deep/.el-button--default {
        margin-top: 12px;
        border-color: $subActive;
        color: $menuText;
        &:hover {
          border-color: $menuActiveText;
          color: $menuActiveText;
        }
      }
    }
  }
}
.info{
   overflow: hidden;
   padding-left:20px;
   .part{
      width:33%;
      float: left;
      >div{
         margin-bottom:10px;
         >span{
           color:#999;
         }
      }
   }
}
.info2{
   padding-left:20px;
   .row{
      margin-bottom:10px;
      span{
        color:#999;
      }
   }
}
</style>
